/** @type {import('next').NextConfig} */
const path = require('path')
// const { createProxyMiddleware } = require('http-proxy-middleware');
const isProd = process.env.NODE_ENV === 'production';
const nextConfig = {
    // assetPrefix: isDev ? undefined : 'https://static.shutu.cn',
    // distDir: isProd ? '_next_build' : '_next',
    assetPrefix: isProd ? "//js.tuguaishou.com/ips_ai_home/hua" : "",
    async rewrites() {
        return [
            {
                source: '/',
                destination: '/home', 
            },
            {
                source: '/v4/:path*',
                destination: 'https://api.818ps.com/v4/:path*', 
            },
            {
                source: '/:path*',
                destination: 'https://818ps.com/:path*',
            },
        ];
    },
    images: {
        domains: [],
        unoptimized: true //nextjs 12.3.0 之后生效
    },
    publicRuntimeConfig: {
        env: {
            NODE_ENV: process.env.NODE_ENV
        }
    },
    serverRuntimeConfig: {
        env: {
            NODE_ENV: process.env.NODE_ENV
        }
    },
    sassOptions: {
        includePaths: [path.join(__dirname, 'styles')],
    },
    // next 兼容 ant-mobile
    transpilePackages: ['antd-mobile'],
}
  
module.exports = nextConfig
